package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.bean.IsBuyBean;
import com.xuxin.baby.bean.VideoBean;
import com.xuxin.baby.bean.VideoCollectedBean;
import com.xuxin.baby.contract.VideoContract;
import com.xuxin.baby.model.VideoModel;

/**
 * Created by xu_xin
 * Created on 2020/11/2 0002
 * 视频播放
 */
public class VideoPresenter implements VideoContract.Presenter {
    private final VideoModel model;
    private final VideoContract.View view;

    public VideoPresenter(VideoContract.View view) {
        this.view = view;
        model = new VideoModel();
    }

    @Override
    public void getVideo(String tenantId, String token, String videoId) {
        if (null != model) {
            model.getVideo(this, tenantId, token, videoId);
        }
    }

    @Override
    public void isCollected(String tenantId, String token, String memberId, String videoId) {
        if (null != model) {
            model.isCollected(this, tenantId, token, memberId, videoId);
        }
    }

    @Override
    public void isBuy(String tenantId, String token, String memberId, String videoId) {
        if (null != model) {
            model.isBuy(this, tenantId, token, memberId, videoId);
        }
    }

    @Override
    public void onSuccess(VideoBean videoBean) {
        if (null != view) {
            view.onSuccess(videoBean);
        }
    }

    @Override
    public void onSuccess(VideoCollectedBean videoCollectedBean) {
        if (null != view) {
            view.onSuccess(videoCollectedBean);
        }
    }

    @Override
    public void onSuccess(IsBuyBean isBuyBean) {
        if (null != view) {
            view.onSuccess(isBuyBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}